package com.example.firstdemo.ui.screens.splash

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.firstdemo.R
import com.example.firstdemo.ui.theme.AppTheme
import com.example.firstdemo.ui.theme.full

@Composable
fun SplashScreen() {
    Surface(
        modifier = Modifier
            .fillMaxWidth()
            .fillMaxHeight(),
    ) {
        Box(
            contentAlignment = Alignment.TopCenter,
            modifier = Modifier.background(
                brush = Brush.linearGradient(
                    listOf<Color>(
                        Color(0xFF7EE8FA), Color(0xFFEEC0C6)
                    ),
                    start = Offset(0f, 0f)
                )
            )
        ) {
            Column(
                horizontalAlignment = Alignment.CenterHorizontally,
                modifier = Modifier.fillMaxHeight()
            ) {
                Spacer(Modifier.height(150.dp))
                Box(
                    Modifier
                        .size(130.dp)
                        .border(3.dp, MaterialTheme.colorScheme.primary, MaterialTheme.shapes.full),
                    contentAlignment = Alignment.Center
                ) {
                    Image(
                        painterResource(R.drawable.logo),
                        "",
                        contentScale = ContentScale.Fit,
                        modifier = Modifier.fillMaxSize(0.8f)
                    )
                }
                Text(
                    "TFDS",
                    style = MaterialTheme.typography.titleLarge,
                    fontSize = 30.sp,
                    modifier = Modifier.padding(top = 10.dp),
                    color = MaterialTheme.colorScheme.onBackground
                )
            }
        }
    }
}

@Preview(
    showSystemUi = true,
    showBackground = true
)
@Composable
fun GreetingPreview() {
    AppTheme {
        SplashScreen()
    }
}